import { ApiPropertyOptional, PickType } from '@nestjs/swagger';
import { IsOptional, IsByteLength, IsEnum, IsInt } from 'class-validator';
import { Whether } from 'src/common/constants/database-enum.const';
import { DataLength } from 'src/common/constants/database-enum.const';

export class UpdateFavoritesDto {
  @ApiPropertyOptional({ description: '收藏夹用户id', required: true })
  @IsOptional()
  @IsInt()
  readonly favorites_uid?: number;

  @ApiPropertyOptional({ description: '收藏夹描述' })
  @IsOptional()
  readonly favorites_remarks?: string;

  @ApiPropertyOptional({ description: '收藏夹名' })
  @IsOptional()
  @IsByteLength(0, DataLength.Long)
  readonly favorites_name?: string;

  @ApiPropertyOptional({ description: '收藏夹封面' })
  @IsOptional()
  @IsByteLength(0, DataLength.Long)
  readonly favorites_cover?: string;

  @ApiPropertyOptional({ description: '是否公开', default: Whether.N })
  @IsOptional()
  @IsEnum(Whether)
  readonly is_public?: Whether;

  @ApiPropertyOptional({
    description: '是否是默认收藏夹',
    default: Whether.N,
  })
  @IsOptional()
  @IsEnum(Whether)
  readonly is_default?: Whether;
}

export class UpdateUserFavoritesDto extends PickType(UpdateFavoritesDto, [
  'favorites_remarks',
  'favorites_name',
  'favorites_cover',
  'is_public',
]) {}
